<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge">
		<title>{$pageData.title}</title>
		<link rel="stylesheet" href="__STATIC__/home/js/layui/css/layui.css" />
		<link rel="stylesheet" href="__STATIC__/home/css/admin.css" />
		<script type="text/javascript" src="__STATIC__/home/js/jquery.min.js"></script>
		<script type="text/javascript" src="__STATIC__/home/js/layui/layui.js"></script>
	</head>

	<body class="pd30" data-id="userPhoneChange">
		<div class="center-nav f20">{$pageData.title}</div>
		<div class="center-from b-w">
			<form class="layui-form">
				<input type="hidden" id="token" value="{$token}" name="token">
				<ul class="center-from-ul clearfix">
					<li class="width6">
						<div class="layui-form-item">
							<label class="layui-form-label">手机号码</label>
							<div class="layui-input-block">
								<span style="line-height: 32px;">{$phone}</span>
							</div>
						</div>
					</li>
					<li>
						<div class="layui-form-item">
							<label class="layui-form-label">短信验证码</label>
							<div class="layui-input-inline">
								<input type="text" name="smscode" autocomplete="off" placeholder="请输入短信验证码" class="layui-input">
							</div>
							<div class="layui-input-inline" style="width: 120px;">
								<input type="button" autocomplete="off" value="获取验证码" id="userPhoneSend" class="layui-btn layui-bg-orange">
							</div>
						</div>
					</li>
				</ul>
				<p class="center-from-p"><input type="button" lay-submit="submit" lay-filter="userPhoneChangeSubmit" class="layui-btn layui-bg-orange" value="验证手机号码"></p>
			</form>
		</div>
		
		<script type="text/javascript">
//			function checkUserSmsCode() {
//				$.ajax({
//					'type': 'post',
//					'dataType': 'json',
//					'data': 'smscode=' + $("form[name=oldPhone] input[name=smscode]").val() + '&token={$token}',
//					'url': "{:url('sms.handle/check_smscode')}",
//					'success': function(data) {
//						if(data.code == 1) {
//							newPhone();
//						} else {
//							alert(data.msg);
//						}
//					}
//				});
//			}

			function newPhone() {
				var html = '<form name="newPhone"><p>新手机号码：<input name="phone"></p><p>短信验证码：<input name="smscode"><a href="javascript:;" onclick="sendSms2()">发送验证码</a></p><p><input type="button" value="绑定新手机" onclick="bindPhone()"></p><p><input type="hidden" name="token" value="{$token}"></p></form>';
				$("#bindPhone").html(html);
			}

			function bindPhone() {
				var postData = $("form[name=newPhone]").serialize();
				$.ajax({
					'type': 'post',
					'dataType': 'json',
					'data': postData,
					'url': "{:url('user.handle/bind_phone')}",
					'success': function(data) {

					}
				});
			}

			function sendSms() {
				$.ajax({
					'type': 'post',
					'dataType': 'json',
					'data': 'token={$token}',
					'url': "{:url('sms.handle/send_smscode')}",
					'success': function(data) {
						alert(data.msg);
					}
				});
			}

			function sendSms2() {
				var phone = $("form[name=newPhone] input[name=phone]").val();
				$.ajax({
					'type': 'post',
					'dataType': 'json',
					'data': 'phone=' + phone + '&token={$token}',
					'url': "{:url('sms.handle/send_smscode2')}",
					'success': function(data) {
						alert(data.msg);
					}
				});
			}
		</script>
		<script>
			var sendSmscodeSrc="{:url('sms.handle/send_smscode')}";
			var sendSmscodeSrc1="{:url('sms.handle/send_smscode2')}";
			//验证手机号码
			var checkSmscodeSrc="{:url('sms.handle/check_smscode')}";
			
			//重新绑定
			var cbindPhoneSrc="{:url('user.handle/bind_phone')}";
		</script>
		<script type="text/javascript" src="__STATIC__/home/js/public.js"></script>
	</body>

</html>